﻿#region Header

/*
Behavioral Rating of Dancing Human Crowds based on Motion Patterns
By

Pascal Hauser 
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

and

Raphael Gfeller
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

*/

#endregion

#region Usings

using System;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using paravili.Steps;

#endregion

namespace Tests.Basics.Steps {
	/// <summary>
	/// Description of the class
	/// </summary>
	[TestClass]
	public class TestStringToPointConvertor {
		#region Test Methods

		// public methods located here

		[TestMethod]
		public void TestEmptyString() {
			var testCandidate = new ManuallyCropDeadRegions.StringToPointConvertor();

			Point[] result = testCandidate.ConvertFromString(string.Empty);

			Assert.IsTrue(result.Length == 0);
		}

		[TestMethod]
		public void TestNull() {
			var testCandidate = new ManuallyCropDeadRegions.StringToPointConvertor();

			Point[] result = testCandidate.ConvertFromString(null);

			Assert.IsTrue(result.Length == 0);
		}

		[TestMethod]
		public void TestOnePoint() {
			var testCandidate = new ManuallyCropDeadRegions.StringToPointConvertor();

			Point[] result = testCandidate.ConvertFromString("12,20");

			Assert.IsTrue(result.Length == 1);
			Assert.IsTrue(result[0].X == 12 && result[0].Y == 20);
		}

		[TestMethod]
		public void TestNoPointInformation() {
			var testCandidate = new ManuallyCropDeadRegions.StringToPointConvertor();
			Point[] result = testCandidate.ConvertFromString(";;;");
			Assert.IsTrue(result.Length == 0);
		}

		[TestMethod]
		public void TestPointNoPointInformation() {
			var testCandidate = new ManuallyCropDeadRegions.StringToPointConvertor();
			Point[] result = testCandidate.ConvertFromString("2,2;;;");
			Assert.IsTrue(result.Length == 1);
		}

		[TestMethod]
		public void TestSpacesAtBeginning() {
			var testCandidate = new ManuallyCropDeadRegions.StringToPointConvertor();
			Point[] result = testCandidate.ConvertFromString(" 2,2;");
			Assert.IsTrue(result.Length == 1);
			Assert.IsTrue(result[0].X == 2 && result[0].Y == 2);
		}

		[TestMethod]
		public void TestPointXIsA() {
			var testCandidate = new ManuallyCropDeadRegions.StringToPointConvertor();

			try {
				Point[] result = testCandidate.ConvertFromString("a,20;");
			}
			catch (FormatException) {
				Assert.IsTrue(true);
				return;
			}
			Assert.Fail();
		}

		[TestMethod]
		public void TestTwoPoint() {
			var testCandidate = new ManuallyCropDeadRegions.StringToPointConvertor();

			Point[] result = testCandidate.ConvertFromString("12,20;4,2");

			Assert.IsTrue(result.Length == 2);
			Assert.IsTrue(result[0].X == 12 && result[0].Y == 20);
			Assert.IsTrue(result[1].X == 4 && result[1].Y == 2);
		}

		[TestMethod]
		public void TestInvalidPointFormat() {
			var testCandidate = new ManuallyCropDeadRegions.StringToPointConvertor();

			try {
				Point[] result = testCandidate.ConvertFromString("12,20,4;");
			}
			catch (FormatException) {
				Assert.IsTrue(true);
				return;
			}
			Assert.Fail();
		}

		[TestMethod]
		public void TestInvalidPointsFormat() {
			var testCandidate = new ManuallyCropDeadRegions.StringToPointConvertor();

			try {
				Point[] result = testCandidate.ConvertFromString("12,20;12,12,3;123,2;");
			}
			catch (FormatException) {
				Assert.IsTrue(true);
				return;
			}
			Assert.Fail();
		}

		#endregion
	}
}